package com.xinqi.xinqidev.publisher.consumer.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.converter.MessageConversionException;
import org.springframework.stereotype.Component;

/**
 * @author xin麒
 * @date 2023/12/1 23:11
 */
@Component
@Slf4j
public class MqListener {

    //这个不会将消息删除
//    @RabbitListener(queues = "simple.queue")
//    public void listenSimpleQueue(String msg){
//        log.debug(msg + " is SimpleQueue message ......");
//        throw new RuntimeException("不小心故意的");
//    }

    //这个会将消息删除
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg){
        log.debug(msg + " is SimpleQueue message ......");
        throw new MessageConversionException("故意的");
    }


}
